import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/widgets.dart';
import 'package:mobile_app.core/core/presentation/widgets/shake_built_transition.dart';
import 'package:mobile_app.home.core/core/presentation/theme/home_core_theme.dart';
import 'package:mobile_app.home.core/core/presentation/widgets/card_button.dart';

class TranslationSelectionCardWrongAnswerButton extends StatelessWidget {
  const TranslationSelectionCardWrongAnswerButton({
    required this.title,
    required this.shakeAnimationController,
    required this.onPressed,
    this.autoSizeGroup,
    super.key,
  });

  final String title;
  final AnimationController shakeAnimationController;
  final VoidCallback onPressed;
  final AutoSizeGroup? autoSizeGroup;

  @override
  Widget build(BuildContext context) {
    return CardButton(
      onPressed: onPressed,
      child: Padding(
        padding: const EdgeInsets.symmetric(
          vertical: 8,
          horizontal: 14,
        ),
        child: ShakeBuiltTransition(
          controller: shakeAnimationController,
          child: AutoSizeText(
            title,
            style: HomeCoreTheme.of(context).textTheme.cardButton,
            textAlign: TextAlign.center,
            maxLines: 2,
            stepGranularity: 0.1,
            wrapWords: false,
            minFontSize: 8,
            overflow: TextOverflow.ellipsis,
            group: autoSizeGroup,
          ),
        ),
      ),
    );
  }
}
